//
//  SMLoginViewController.m
//  ShoppingMall
//
//  Created by Demon on 2018/3/26.
//  Copyright © 2018年 Demon. All rights reserved.
//

#import "SMLoginViewController.h"

@interface SMLoginViewController ()

@property (weak, nonatomic) IBOutlet UITextField *telPhoneTF;
@property (weak, nonatomic) IBOutlet UITextField *pwdtf;

@end

@implementation SMLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction)cancelActionClick:(UIBarButtonItem *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)loginBtnClick:(id)sender {
    MBProgressHUD *hud = [MBProgressHUD showIndeterminateAndText:self.view text:@"正在登录..."];
    [[YDNetClient sharedInstance] getMethod:@"http://jidianping.com/api/tb/register/login.php" param:@{@"phonenum":self.telPhoneTF.text,@"psw":self.pwdtf.text} success:^(id object) {
        [hud hideAnimated:YES];
        set_login_status(YES);
        set_userdefault(kUserTelPhone, self.telPhoneTF.text);
        [self dismissViewControllerAnimated:YES completion:nil];
    } fail:^(NSError *error) {
        [hud hideAnimated:YES];
        [MBProgressHUD showError:@"登录失败"];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
